<!-- Footer -->
<div id="footer" class="center">
<p>
<?php

/**
 * Function to easily insert a string.
 *
 * $str1	source string
 * $str2	string to insert
 * $pos	position to start insert
 */
function strIns($str1, $str2, $pos) {
	$temp1 = substr($str1, 0, $pos);
	$temp2 = substr($str1, $pos, strlen($str1));
	
	return $temp1.$str2.$temp2;
}

/**
 * Function to easily delete from a string.
 *
 * $str1	source string
 * $pos1	start position
 * $pos2	ending position
 */
function strDel($str1, $pos1, $pos2) {
	$temp1 = substr($str1, 0, $pos1);
	$temp2 = substr($str1, $pos2, strlen($str1));
	
	return $temp1.$temp2;
}

// The following section is responsible for finding the current document and bolding the link to indicate that it is active.
// Set up the footer links string.
$footers = array('contact_us', 'faq', 'terms_service');
$footerLinks = array('contact_us' => 'Contact Us', 'faq' => 'FAQ', 'terms_service' => 'Terms of Service');
$footerUrls = array(
	'contact_us' => array('controller' => 'users', 'action' => 'contact_us'),
	'faq' => array('controller' => 'pages', 'action' => 'faq'),
	'terms_service' => array('controller' => 'pages', 'action' => 'terms_service'),
	'home' => array('controller' => 'pages', 'action' => 'home')
);

// The current document.
// Find the positions necessary for the operation.
$curDocName = basename(ROUTER::url('', false));
$links = '';

$valid = false;
foreach($footers as $footer) {
	if($curDocName == $footer) {
		$valid = true;
	}
}

if(!$valid) {
	if($curDocName == 'login' || $curDocName == '') {
		$curDocName = 'home';
		$valid = true;
	}
}

for($i = 0; $i < count($footers); $i++) {
	if($curDocName == $footers[$i]) {
		$links .= '<span class="bold">'.$footerLinks[$footers[$i]].'</span>';
	} else {
		$links .= $html->link($footerLinks[$footers[$i]], $footerUrls[$footers[$i]]);
	}
	
	if($i + 1 != count($footers)) {
		$links .= ' | ';
	}
}

echo($links.'<br />');
?>
Copyright &#169; 2009 by U-MO. All rights reserved.
</p>
</div>
<!-- End Footer -->
